<?php
	/**
	 * This is a quick-and-dirty draft QPanel object to do Create, Edit, and Delete functionality
	 * of the TablePortfolio class.  It uses the code-generated
	 * TablePortfolioMetaControl class, which has meta-methods to help with
	 * easily creating/defining controls to modify the fields of a TablePortfolio columns.
	 *
	 * Any display customizations and presentation-tier logic can be implemented
	 * here by overriding existing or implementing new methods, properties and variables.
	 * 
	 * NOTE: This file is overwritten on any code regenerations.  If you want to make
	 * permanent changes, it is STRONGLY RECOMMENDED to move both table_portfolio_edit.php AND
	 * table_portfolio_edit.tpl.php out of this Form Drafts directory.
	 *
	 * @package My Application
	 * @subpackage Drafts
	 */
	class TablePortfolioEditPanel extends QPanel {
		// Local instance of the TablePortfolioMetaControl
		protected $mctTablePortfolio;

		// Controls for TablePortfolio's Data Fields
		public $lblId;
		public $lstUser;
		public $txtBoothId;
		public $txtCategoryId;
		public $txtSubcategoryId;
		public $txtColorsId;
		public $txtFeelsId;
		public $txtPortfolioCategoryId;
		public $txtTitle;
		public $txtPortfolioImage;
		public $txtPortfolioThumnail;
		public $txtFilename;
		public $txtFilenameThumnail;
		public $txtUrl;
		public $txtUrlThumnail;
		public $txtKeyword1;
		public $txtKeyword2;
		public $txtKeyword3;
		public $txtKeyword4;
		public $txtKeyword5;
		public $txtKeyword6;
		public $txtKeyword7;
		public $txtKeyword8;
		public $txtKeyword9;
		public $txtKeyword10;
		public $calRegisterDate;
		public $txtStatus;
		public $txtActive;

		// Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References

		// Other Controls
		public $btnSave;
		public $btnDelete;
		public $btnCancel;

		// Callback
		protected $strClosePanelMethod;

		public function __construct($objParentObject, $strClosePanelMethod, $intId = null, $strControlId = null) {
			// Call the Parent
			try {
				parent::__construct($objParentObject, $strControlId);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}

			// Setup Callback and Template
			$this->strTemplate = 'TablePortfolioEditPanel.tpl.php';
			$this->strClosePanelMethod = $strClosePanelMethod;

			// Construct the TablePortfolioMetaControl
			// MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
			$this->mctTablePortfolio = TablePortfolioMetaControl::Create($this, $intId);

			// Call MetaControl's methods to create qcontrols based on TablePortfolio's data fields
			$this->lblId = $this->mctTablePortfolio->lblId_Create();
			$this->lstUser = $this->mctTablePortfolio->lstUser_Create();
			$this->txtBoothId = $this->mctTablePortfolio->txtBoothId_Create();
			$this->txtCategoryId = $this->mctTablePortfolio->txtCategoryId_Create();
			$this->txtSubcategoryId = $this->mctTablePortfolio->txtSubcategoryId_Create();
			$this->txtColorsId = $this->mctTablePortfolio->txtColorsId_Create();
			$this->txtFeelsId = $this->mctTablePortfolio->txtFeelsId_Create();
			$this->txtPortfolioCategoryId = $this->mctTablePortfolio->txtPortfolioCategoryId_Create();
			$this->txtTitle = $this->mctTablePortfolio->txtTitle_Create();
			$this->txtPortfolioImage = $this->mctTablePortfolio->txtPortfolioImage_Create();
			$this->txtPortfolioThumnail = $this->mctTablePortfolio->txtPortfolioThumnail_Create();
			$this->txtFilename = $this->mctTablePortfolio->txtFilename_Create();
			$this->txtFilenameThumnail = $this->mctTablePortfolio->txtFilenameThumnail_Create();
			$this->txtUrl = $this->mctTablePortfolio->txtUrl_Create();
			$this->txtUrlThumnail = $this->mctTablePortfolio->txtUrlThumnail_Create();
			$this->txtKeyword1 = $this->mctTablePortfolio->txtKeyword1_Create();
			$this->txtKeyword2 = $this->mctTablePortfolio->txtKeyword2_Create();
			$this->txtKeyword3 = $this->mctTablePortfolio->txtKeyword3_Create();
			$this->txtKeyword4 = $this->mctTablePortfolio->txtKeyword4_Create();
			$this->txtKeyword5 = $this->mctTablePortfolio->txtKeyword5_Create();
			$this->txtKeyword6 = $this->mctTablePortfolio->txtKeyword6_Create();
			$this->txtKeyword7 = $this->mctTablePortfolio->txtKeyword7_Create();
			$this->txtKeyword8 = $this->mctTablePortfolio->txtKeyword8_Create();
			$this->txtKeyword9 = $this->mctTablePortfolio->txtKeyword9_Create();
			$this->txtKeyword10 = $this->mctTablePortfolio->txtKeyword10_Create();
			$this->calRegisterDate = $this->mctTablePortfolio->calRegisterDate_Create();
			$this->txtStatus = $this->mctTablePortfolio->txtStatus_Create();
			$this->txtActive = $this->mctTablePortfolio->txtActive_Create();

			// Create Buttons and Actions on this Form
			$this->btnSave = new QButton($this);
			$this->btnSave->Text = QApplication::Translate('Save');
			$this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
			$this->btnSave->CausesValidation = $this;

			$this->btnCancel = new QButton($this);
			$this->btnCancel->Text = QApplication::Translate('Cancel');
			$this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));

			$this->btnDelete = new QButton($this);
			$this->btnDelete->Text = QApplication::Translate('Delete');
			$this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('TablePortfolio') . '?'));
			$this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
			$this->btnDelete->Visible = $this->mctTablePortfolio->EditMode;
		}

		// Control AjaxAction Event Handlers
		public function btnSave_Click($strFormId, $strControlId, $strParameter) {
			// Delegate "Save" processing to the TablePortfolioMetaControl
			$this->mctTablePortfolio->SaveTablePortfolio();
			$this->CloseSelf(true);
		}

		public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
			// Delegate "Delete" processing to the TablePortfolioMetaControl
			$this->mctTablePortfolio->DeleteTablePortfolio();
			$this->CloseSelf(true);
		}

		public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
			$this->CloseSelf(false);
		}

		// Close Myself and Call ClosePanelMethod Callback
		protected function CloseSelf($blnChangesMade) {
			$strMethod = $this->strClosePanelMethod;
			$this->objForm->$strMethod($blnChangesMade);
		}
	}
?>